package com.zg.paging3.activity.java;

import android.os.Build;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.DiffUtil;

import com.zg.paging3.activity.java.model.ArticleBeanInJava;

/***
 * @Author: zxd
 * @CreateDate: 2021/7/16 13:58
 * @Description:
 */
public class ArticleDiffCallback extends DiffUtil.ItemCallback<ArticleBeanInJava> {

    @Override
    public boolean areItemsTheSame(@NonNull ArticleBeanInJava oldItem, @NonNull ArticleBeanInJava newItem) {
        return oldItem.getId() == newItem.getId();
    }

    @Override
    public boolean areContentsTheSame(@NonNull ArticleBeanInJava oldItem, @NonNull ArticleBeanInJava newItem) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            return oldItem.equals(newItem);
        }
        return false;
    }
}
